﻿using System;
using NUnit.Framework;

namespace TimeRelated
{
	[TestFixture]
	public class SimplerTimeTest
	{
		[Test]
		public void ShouldResolveToToday_WhenOtherDateIsSameAsPivotDate() {
			DateTime pivotDate = new DateTime(2009, 9, 21);
			DateTime otherDate = new DateTime(2009, 9, 21);
			
			Assert.That(SimplerTime.DaysFromNow(pivotDate, otherDate), Is.EqualTo("Today"));
		}
		
		[Test]
		public void ShouldResolveToYesterday_WhenOtherDateIsOneDayPrior() {
			DateTime pivotDate = new DateTime(2009, 9, 21);
			DateTime otherDate = new DateTime(2009, 9, 20);
			
			Assert.That(SimplerTime.DaysFromNow(pivotDate, otherDate), Is.EqualTo("Yesterday"));
		}
				
		[Test]
		public void ShouldResolveToYesterday_WhenOtherDateIsOneDayPrior_ButOccursInPreviousMonth() {
			DateTime pivotDate = new DateTime(2009, 10, 1);
			DateTime otherDate = new DateTime(2009, 9, 30);
			
			Assert.That(SimplerTime.DaysFromNow(pivotDate, otherDate), Is.EqualTo("Yesterday"));
		}
		
		[Test]
		public void ShouldResolveTo8DaysAgo_WhenOtherDateIs8DaysPrior() {
			DateTime pivotDate = new DateTime(2009, 9, 21);
			DateTime otherDate = new DateTime(2009, 9, 13);
			
			Assert.That(SimplerTime.DaysFromNow(pivotDate, otherDate), Is.EqualTo("8 days ago"));
		}
				
		[Test]
		public void ShouldResolveToNextWeek_WhenOtherDateIs7DaysAhead() {
			DateTime pivotDate = new DateTime(2009, 10, 1);
			DateTime otherDate = new DateTime(2009, 10, 8);
			
			Assert.That(SimplerTime.DaysFromNow(pivotDate, otherDate), Is.EqualTo("Next week"));
		}
	}
}
